<?php
require_once 'hello_madal_db_mvc/Model/model_require_once.php';
require_once 'hello_madal_db_mvc/View/Includes/view_require_once.php';
?>
<script type="text/javascript">
<?php
require_once 'hello_madal_db_mvc/Model/hello_madal_db_javascript_classes.min.js';
?>

function refreshPage(){
	//simple (but ineffient) way to get the new data
	window.location.reload();
}
</script>

<title>Hello MADAL World</title>

<h1>Hello MADAL World</h1>
<?php

//print out a field for inserting new Makes
Make::print_Make_add ( "refreshPage" );

//get all the existing makes from the database
$makes = Make::getMakes ();

//create the javascript objects for updating the database
Make::instantiate_javascript_objects ( $makes );

?>
<h2>Makes</h2>
<table>
	<tr>
		<th>Make Id</th>
		<th>Name</th>
	</tr>
<?php
/* @var $make Make */
foreach ( $makes as $make ) {
	?>
	<tr>
		<td><?php
	echo $make->get_make_id ();
	?></td>
		<td><?php
	$make->print_make_name_input_setter ();
	?></td>
		<td>
	<?php
	$make->print_delete_button ( true, "refreshPage" );
	?>
	</td>
	</tr>
<?php
}
?>
</table>

<script type="text/javascript">
$(
function(){
	//apply button formatting
	pageLoaded();
}
		);
</script>